﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using MySql.Data.MySqlClient; 

namespace CapaDatos
{
    
        public static class Datos
        {
            //parametro modificado.
            //private static string connectionString = "Server=localhost;Database=supermercado;Uid=admin;Pwd=admin;";
            private static string connectionString = "Server=localhost;Database=supermercado;Uid=root;Pwd=;Allow Zero Datetime=True;Convert Zero Datetime=True";


            public static string ConnectionString
            {
                get { return Datos.connectionString; }
                set { Datos.connectionString = value; }
            }

            //metodo..
            public static DataSet ConsultarEx(string consulta)
            {
                MySqlConnection cn = null;
                try
                {
                    cn = new MySqlConnection(connectionString);
                    cn.Open(); //abre BD
                    MySqlDataAdapter da = new MySqlDataAdapter(consulta, cn);
                    DataSet ds = new DataSet();
                    da.Fill(ds);
                    cn.Close();//Cierra BD

                    return ds;
                }
                catch (Exception ex)
                {
                    if (cn != null)
                    cn.Close();

                    throw ex;
                }
            }
    
    }//fin clase
}//fin namespace
